<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>博客详情</title>
    <base href="<%=request.getContextPath()%>/">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" href="static/common/css/base.css">
    <link rel="stylesheet" href="static/common/css/author-list.css">
    <script src="static/jquery/jquery.js"></script>
    <script src="static/jquery/js.cookie.js"></script>
    <script src="static/layui/layui.js"></script>
    <link rel="icon" href="static/images/favicon.ico">
</head>
<body>
<div class="main">
    <div class="body">
        <div class="content">
            <div class="layui-field-box">
                <div id="authorList" class="author-list"></div>
            </div>
            <div id="pageTool" style="margin: 10px auto;text-align: center"></div>
        </div>
    </div>
</div>

</body>
<script src="static/common/js/ajax.js"></script>
<script src="static/common/js/base.js"></script>
<script src="static/common/js/author.js"></script>
<script>
    const articleId = "${articleId}";
    const type = "${type}";
    const pageInfo = {
        page: 1,
        limit: 5
    };
    const laypage = layui.laypage;
    getAuthorPage();

    function getAuthorPage() {
        let url = "";
        if (type === "1") {
            url = "article/" + articleId + "/like";
        } else {
            url = "article/" + articleId + "/collection";
        }
        http.get(url, pageInfo, function (res) {
            createAuthorList("authorList", res.data)
            if (res.count >= pageInfo.limit) {
                laypage.render({
                    elem: "pageTool",
                    count: res.count,
                    limit: pageInfo.limit,
                    curr: pageInfo.page,
                    jump: function (obj, first) {
                        pageInfo.page = obj.curr
                        pageInfo.limit = obj.limit
                        // 首次不执行
                        if (!first) {
                            getAuthorPage()
                        }
                    }
                })
            }
        })
    }
</script>
</html>
